#{extends 'admin.html' /}
#{set title:'Administration : Ajout d\'une Disponibilité' /}
#{if flash.error}
    <h4 class="alert_error">${flash.error}</h4>
#{/if}

<article class="module width_full">
    <header><h3 class="tabs_involved">Ajouter une disponibilité</h3>
        <ul class="tabs">
            <li><a href="@{Admin.index}">Annuler</a></li>
        </ul>

    </header>
    <div class="entity">
        #{form @Availabilities.save(), id:'createForm'}
        <div class="module_content">
            <fieldset>
                <label>Date de diponibilité</label>
                
                	<input id="date" type="date" name="entity.date" value="${entity?.date}" size="10" />
            
                <span class="error">${errors.forKey('entity.date')}</span>
            </fieldset>
            <fieldset>
                <label>Vehicule : </label>
                <select name="entity.vehicule.id">
                          
              
        %{ models.Vehicule.all().fetch().sort{ it.toString() }.each() { }%
          
          %{
            selected = false;
            if (entity?.vehicule?.id == it.id) {
              selected = true
            }
          }%
          <option value="${it?.id}" ${selected ? 'selected'.raw() : ''}>${it}</option>
        %{ } }%
        </select>
                <span class="error">${errors.forKey('entity.vehicule')}</span>
            </fieldset>
            <fieldset>
                <label>Circuit : </label>
                <select name="entity.circuit.id">
                          
              
        %{ models.Circuit.all().fetch().sort{ it.toString() }.each() { }%
          
          %{
            selected = false;
            if (entity?.circuit?.id == it.id) {
              selected = true
            }
          }%
          <option value="${it?.id}" ${selected ? 'selected'.raw() : ''}>${it}</option>
        %{ } }%
        </select>
                <span class="error">${errors.forKey('entity.circuit')}</span>
            </fieldset>
            <fieldset>
                <label>Moniteur : </label>
                <select name="entity.employee.id">
                          
              
        %{ models.Employee.all().fetch().sort{ it.toString() }.each() { }%
          
          %{
            selected = false;
            if (entity?.employee?.id == it.id) {
              selected = true
            }
          }%
          <option value="${it?.id}" ${selected ? 'selected'.raw() : ''}>${it}</option>
        %{ } }%
        </select>
                <span class="error">${errors.forKey('entity.employee')}</span>
            </fieldset>
            <input type="hidden" name="entity.id" value="${entity?.id}"/>
        </div>
        <footer>
            <div class="submit_link">
                <input type="submit" name="submit" value="Créer !" class="alt_btn"/>
            </div>
        </footer>
        #{/form}
    </div>
</article>